<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>chigraph: lib/core/include/chi/LangModule.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="chigraphDoxygenIcon.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">chigraph
   &#160;<span id="projectnumber">master</span>
   </div>
   <div id="projectbrief">Systems programming language written for beginners in LLVM</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('LangModule_8hpp_source.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">LangModule.hpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="LangModule_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#ifndef CHI_LANG_MODULE_HPP</span></div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="preprocessor">#define CHI_LANG_MODULE_HPP</span></div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;</div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="preprocessor">#pragma once</span></div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;</div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="ChiModule_8hpp.html">chi/ChiModule.hpp</a>&quot;</span></div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="core_2include_2chi_2Fwd_8hpp.html">chi/Fwd.hpp</a>&quot;</span></div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;</div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">#include &lt;unordered_map&gt;</span></div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;</div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacechi.html">chi</a> {</div><div class="line"><a name="l00016"></a><span class="lineno"><a class="line" href="structchi_1_1LangModule.html">   16</a></span>&#160;<span class="keyword">struct </span><a class="code" href="structchi_1_1LangModule.html">LangModule</a> : <a class="code" href="structchi_1_1ChiModule.html">ChiModule</a> {</div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;    <a class="code" href="structchi_1_1LangModule.html#a0d623aa2342eec20ab11150e793f6b9e">LangModule</a>(<a class="code" href="structchi_1_1Context.html">Context</a>&amp; ctx);</div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;</div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;    <a class="code" href="structchi_1_1LangModule.html#adf246308e91faa5f0db890331ab573ce">~LangModule</a>();</div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;</div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;    <a class="code" href="structchi_1_1Result.html">Result</a> <a class="code" href="structchi_1_1LangModule.html#a7d02bd6785e656a90820c6f0d0ffe3d6">nodeTypeFromName</a>(boost::string_view name, <span class="keyword">const</span> nlohmann::json&amp; jsonData,</div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;                            std::unique_ptr&lt;NodeType&gt;* toFill) <span class="keyword">override</span>;</div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;</div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;    <a class="code" href="structchi_1_1DataType.html">DataType</a> <a class="code" href="structchi_1_1LangModule.html#a1816ac13d6fc10d5ae730f8cf0a92409">typeFromName</a>(boost::string_view name) <span class="keyword">override</span>;</div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;</div><div class="line"><a name="l00029"></a><span class="lineno"><a class="line" href="structchi_1_1LangModule.html#ac9dd298b9bded983c59ba4110bac8698">   29</a></span>&#160;    std::vector&lt;std::string&gt; <a class="code" href="structchi_1_1LangModule.html#ac9dd298b9bded983c59ba4110bac8698">nodeTypeNames</a>()<span class="keyword"> const override </span>{</div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;        std::vector&lt;std::string&gt; ret;</div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;        ret.reserve(nodes.size());</div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;</div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;        std::transform(nodes.begin(), nodes.end(), std::back_inserter(ret),</div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;                       [](<span class="keyword">auto</span> pair) { <span class="keywordflow">return</span> pair.first; });</div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;</div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;        <span class="keywordflow">return</span> ret;</div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;    }</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;</div><div class="line"><a name="l00039"></a><span class="lineno"><a class="line" href="structchi_1_1LangModule.html#a237b2e36e1c6c909ec9df48b52f7b596">   39</a></span>&#160;    std::vector&lt;std::string&gt; <a class="code" href="structchi_1_1LangModule.html#a237b2e36e1c6c909ec9df48b52f7b596">typeNames</a>()<span class="keyword"> const override </span>{</div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;        <span class="keywordflow">return</span> {<span class="stringliteral">&quot;i32&quot;</span>, <span class="stringliteral">&quot;i1&quot;</span>, <span class="stringliteral">&quot;float&quot;</span>, <span class="stringliteral">&quot;i8*&quot;</span>};  <span class="comment">// TODO: do i need more?</span></div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;    }</div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;</div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;    <a class="code" href="structchi_1_1Result.html">Result</a> <a class="code" href="structchi_1_1LangModule.html#a38055e01447bcb2956e57984ce467a72">addForwardDeclarations</a>(llvm::Module&amp; module) <span class="keyword">const override</span>;</div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;</div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;    <a class="code" href="structchi_1_1Result.html">Result</a> <a class="code" href="structchi_1_1LangModule.html#a34b200310ad5df72251bc40486e6eb8f">generateModule</a>(llvm::Module&amp; <span class="comment">/*module*/</span>) <span class="keyword">override</span>;</div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;</div><div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;<span class="keyword">private</span>:</div><div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;    std::unordered_map&lt;std::string,</div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;                       std::function&lt;std::unique_ptr&lt;NodeType&gt;(<span class="keyword">const</span> nlohmann::json&amp;, <a class="code" href="structchi_1_1Result.html">Result</a>&amp;)&gt;&gt;</div><div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;        nodes;</div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;    std::unordered_map&lt;std::string, llvm::DIType*&gt; mDebugTypes;</div><div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;};</div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;}  <span class="comment">// namespace chi</span></div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;<span class="preprocessor">#endif  // CHI_LANG_MODULE_HPP</span></div><div class="ttc" id="structchi_1_1LangModule_html_a7d02bd6785e656a90820c6f0d0ffe3d6"><div class="ttname"><a href="structchi_1_1LangModule.html#a7d02bd6785e656a90820c6f0d0ffe3d6">chi::LangModule::nodeTypeFromName</a></div><div class="ttdeci">Result nodeTypeFromName(boost::string_view name, const nlohmann::json &amp;jsonData, std::unique_ptr&lt; NodeType &gt; *toFill) override</div><div class="ttdoc">Create a node type that is in the module from the name and json. </div><div class="ttdef"><b>Definition:</b> <a href="LangModule_8cpp_source.html#l00847">LangModule.cpp:847</a></div></div>
<div class="ttc" id="core_2include_2chi_2Fwd_8hpp_html"><div class="ttname"><a href="core_2include_2chi_2Fwd_8hpp.html">Fwd.hpp</a></div><div class="ttdoc">Forward declares all the chigraph data types. </div></div>
<div class="ttc" id="structchi_1_1LangModule_html"><div class="ttname"><a href="structchi_1_1LangModule.html">chi::LangModule</a></div><div class="ttdoc">The module that provides built-in operations like literals, math operations, etc. ...</div><div class="ttdef"><b>Definition:</b> <a href="LangModule_8hpp_source.html#l00016">LangModule.hpp:16</a></div></div>
<div class="ttc" id="structchi_1_1LangModule_html_ac9dd298b9bded983c59ba4110bac8698"><div class="ttname"><a href="structchi_1_1LangModule.html#ac9dd298b9bded983c59ba4110bac8698">chi::LangModule::nodeTypeNames</a></div><div class="ttdeci">std::vector&lt; std::string &gt; nodeTypeNames() const override</div><div class="ttdoc">Get the possible node type names. </div><div class="ttdef"><b>Definition:</b> <a href="LangModule_8hpp_source.html#l00029">LangModule.hpp:29</a></div></div>
<div class="ttc" id="structchi_1_1LangModule_html_adf246308e91faa5f0db890331ab573ce"><div class="ttname"><a href="structchi_1_1LangModule.html#adf246308e91faa5f0db890331ab573ce">chi::LangModule::~LangModule</a></div><div class="ttdeci">~LangModule()</div><div class="ttdoc">Destructor. </div><div class="ttdef"><b>Definition:</b> <a href="LangModule_8cpp_source.html#l00863">LangModule.cpp:863</a></div></div>
<div class="ttc" id="structchi_1_1LangModule_html_a237b2e36e1c6c909ec9df48b52f7b596"><div class="ttname"><a href="structchi_1_1LangModule.html#a237b2e36e1c6c909ec9df48b52f7b596">chi::LangModule::typeNames</a></div><div class="ttdeci">std::vector&lt; std::string &gt; typeNames() const override</div><div class="ttdoc">Get the possible DataType names. </div><div class="ttdef"><b>Definition:</b> <a href="LangModule_8hpp_source.html#l00039">LangModule.hpp:39</a></div></div>
<div class="ttc" id="structchi_1_1Context_html"><div class="ttname"><a href="structchi_1_1Context.html">chi::Context</a></div><div class="ttdoc">The class that handles the loading, creation, storing, and compilation of modules It also stores a LL...</div><div class="ttdef"><b>Definition:</b> <a href="Context_8hpp_source.html#l00055">Context.hpp:55</a></div></div>
<div class="ttc" id="structchi_1_1ChiModule_html"><div class="ttname"><a href="structchi_1_1ChiModule.html">chi::ChiModule</a></div><div class="ttdoc">An abstract class that represents a module of code in Chigraph Can be compiled to a llvm::Module...</div><div class="ttdef"><b>Definition:</b> <a href="ChiModule_8hpp_source.html#l00024">ChiModule.hpp:24</a></div></div>
<div class="ttc" id="structchi_1_1LangModule_html_a38055e01447bcb2956e57984ce467a72"><div class="ttname"><a href="structchi_1_1LangModule.html#a38055e01447bcb2956e57984ce467a72">chi::LangModule::addForwardDeclarations</a></div><div class="ttdeci">Result addForwardDeclarations(llvm::Module &amp;module) const override</div><div class="ttdoc">Adds forward declartions for the functions in this module. </div><div class="ttdef"><b>Definition:</b> <a href="LangModule_8cpp_source.html#l00910">LangModule.cpp:910</a></div></div>
<div class="ttc" id="structchi_1_1LangModule_html_a1816ac13d6fc10d5ae730f8cf0a92409"><div class="ttname"><a href="structchi_1_1LangModule.html#a1816ac13d6fc10d5ae730f8cf0a92409">chi::LangModule::typeFromName</a></div><div class="ttdeci">DataType typeFromName(boost::string_view name) override</div><div class="ttdoc">Get a DataType from the name. </div><div class="ttdef"><b>Definition:</b> <a href="LangModule_8cpp_source.html#l00871">LangModule.cpp:871</a></div></div>
<div class="ttc" id="structchi_1_1LangModule_html_a34b200310ad5df72251bc40486e6eb8f"><div class="ttname"><a href="structchi_1_1LangModule.html#a34b200310ad5df72251bc40486e6eb8f">chi::LangModule::generateModule</a></div><div class="ttdeci">Result generateModule(llvm::Module &amp;) override</div><div class="ttdoc">Generate a llvm::Module from the module. </div><div class="ttdef"><b>Definition:</b> <a href="LangModule_8cpp_source.html#l00912">LangModule.cpp:912</a></div></div>
<div class="ttc" id="ChiModule_8hpp_html"><div class="ttname"><a href="ChiModule_8hpp.html">ChiModule.hpp</a></div><div class="ttdoc">Defines the ChiModule class. </div></div>
<div class="ttc" id="namespacechi_html"><div class="ttname"><a href="namespacechi.html">chi</a></div><div class="ttdoc">The namespace where chigraph lives. </div><div class="ttdef"><b>Definition:</b> <a href="BitcodeParser_8hpp_source.html#l00012">BitcodeParser.hpp:12</a></div></div>
<div class="ttc" id="structchi_1_1LangModule_html_a0d623aa2342eec20ab11150e793f6b9e"><div class="ttname"><a href="structchi_1_1LangModule.html#a0d623aa2342eec20ab11150e793f6b9e">chi::LangModule::LangModule</a></div><div class="ttdeci">LangModule(Context &amp;ctx)</div><div class="ttdoc">Default constructor, usually called from Context::loadModule(&quot;lang&quot;) </div><div class="ttdef"><b>Definition:</b> <a href="LangModule_8cpp_source.html#l00529">LangModule.cpp:529</a></div></div>
<div class="ttc" id="structchi_1_1DataType_html"><div class="ttname"><a href="structchi_1_1DataType.html">chi::DataType</a></div><div class="ttdoc">A type of data Loose wrapper around llvm::Type*, except it knows which ChiModule it&amp;#39;s in and it embed...</div><div class="ttdef"><b>Definition:</b> <a href="DataType_8hpp_source.html#l00017">DataType.hpp:17</a></div></div>
<div class="ttc" id="structchi_1_1Result_html"><div class="ttname"><a href="structchi_1_1Result.html">chi::Result</a></div><div class="ttdoc">The result object, used for identifiying errors with good diagnostics. </div><div class="ttdef"><b>Definition:</b> <a href="Result_8hpp_source.html#l00072">Result.hpp:72</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_97aefd0d527b934f1d99a682da8fe6a9.html">lib</a></li><li class="navelem"><a class="el" href="dir_a2d5e495f4b604d04f57d90095a59dd6.html">core</a></li><li class="navelem"><a class="el" href="dir_a979adfa99d5a8626731f83d5067598b.html">include</a></li><li class="navelem"><a class="el" href="dir_afbc2aa4d9616322ddf4041ba4f8ade6.html">chi</a></li><li class="navelem"><a class="el" href="LangModule_8hpp.html">LangModule.hpp</a></li>
    <li class="footer">Generated on Sat Sep 16 2017 17:41:35 for chigraph by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
